﻿using System;
using System.Web.Mvc;
using root.Proxies;
using SaaSKit.Taskr.Service;

namespace root.Controllers
{

    public class BaseController : Controller
    {

        protected override void OnActionExecuting(ActionExecutingContext filterContext)
        {

            // Only fetch custom settings during a full page request (GET/POST), 
            // do not fetch settings during an AJAX request.
            if (!filterContext.RequestContext.HttpContext.Request.IsAjaxRequest())
            {
                AdminServiceProxy proxy = new AdminServiceProxy();
                SettingsDTO settings = proxy.GetSettings();
                filterContext.Controller.ViewData["CustomTaskrSettings"] = settings;
            }
        }

    }

}